/*
http = require('http');
var spawn = require('child_process').spawn;
var sys = require('sys')

// log to monitor
var filename = process.ARGV[2];

if (!filename)
  return sys.puts("Usage: node monitor.js filename");

// fire up tail on the log file
var tail = spawn("tail", ["-f", filename]);

http.createServer(function (req, update) {
  update.writeHead(200, {'Content-Type': "text/plain;"});
  tail.stdout.on("data", function (data) {
    update.write(data);
  });
}).listen(8000);
*/

var util = require('util')

var spawn = require('child_process').spawn;

var filename = process.ARGV[2];
if (!filename) return util.puts("Usage: node <server.js> <filename>");

var tail = spawn("tail", ["-f", filename]);

http = require('http');

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': "text/plain;charset=UTF-8"});
  tail.stdout.on("data", function (data) {
    res.write(data);
  });
}).listen(8000);

